<template>
	<view>
		<view>
			<u-form-item class="formItem" :label-width="150" label="名称:"><u-input v-model="name" :border="true" /></u-form-item>
			<u-form-item class="formItem" :label-width="150" label="获取时间:"><u-input v-model="gettime" :border="true" /></u-form-item>
			<u-form-item class="formItem" :label-width="150" label="有效期:"><u-input v-model="validity" :border="true" /></u-form-item>
		</view>
		<view style="padding: 20rpx;">
			<text style="font-size: 30rpx; padding: 20rpx">上传附件：</text>
			<u-upload :action="action" @on-success="upucc"></u-upload>
		</view>
		<view class="btn_body"><view class="btn_save" @click="btnSaveImg">保存</view></view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
export default {
	data() {
		return {
			name: '',
			gettime: '',
			validity: '',
			action: 'http://47.115.35.16:9001//fileInput/tengxun',
			imgUrl: ''
		};
	},
	methods: {
		btnSaveImg() {
			let data = {
				type: '个人证书',
				imgUrl: this.imgUrl,
				validityDate: this.validity,
				createDate: this.gettime,
				certName: this.name
			};
			this.$u.api.getccieUp(data).then(res => {
				this.$refs.uToast.show({
					title: '添加成功',
					type: 'success',
				});
			});
		},
		upucc(d, i, l) {
			let data = JSON.parse(d);
			this.imgUrl = data.path;
		}
	}
};
</script>

<style lang="scss">
.formItem {
	border-bottom: 1rpx solid #eeeeee;
	padding: 20rpx;
}
.btn_save {
	width: 90%;
	padding: 20rpx;
	background: #05B2B5;
	color: #fff;
	border-radius: 50rpx;
	margin: 0 auto;
	text-align: center;
	font-size: 30rpx;
}
.btn_body {
	position: fixed;
	bottom: 160px;
	left: 0;
	right: 0;
}
</style>
